package swtElements;

import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.Section;

public class MySection {
	
	 Section section;
	
	public MySection(FormToolkit toolkit, Form form, String title, boolean description, String descr, boolean fillBoth){
		if(title.length() == 0){
			this.section = toolkit.createSection(form.getBody(), Section.EXPANDED);
			section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
		}else{
			if(fillBoth == false){
				if(description == false){
					this.section = toolkit.createSection(form.getBody(),
							ExpandableComposite.TITLE_BAR | ExpandableComposite.COMPACT);
					section.setForeground(new Color(null, 0, 0, 0));
					section.setText(title);
					section.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
				}else{
					this.section = toolkit.createSection(form.getBody(),
							ExpandableComposite.TITLE_BAR | ExpandableComposite.COMPACT
									| Section.DESCRIPTION);
					section.setDescription(descr);
					section.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL));
					section.setForeground(new Color(null, 0, 0, 0));
					section.setText(title);
				}
			}else{
				this.section = toolkit.createSection(form.getBody(), 
						ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED);
				section.setForeground(new Color(null, 0, 0, 0));
				section.setText(title);
				section.setLayoutData(new GridData(GridData.FILL_BOTH));
			}
		}
	}

	public Composite getSection() {
		return section;
	}

	public void setClient(MyComposite clientTags) {
		section.setClient(clientTags.getComposite());
	}

	public void setTextClient(MyToolBar toolbarPreview) {
		section.setTextClient(toolbarPreview.getToolBar());
	}

	public void setText(String text) {
		section.setText(text);
	}

}
